package org.finesys.common.log.core.aspect;

import lombok.RequiredArgsConstructor;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.finesys.common.log.trace.handler.AroundLogHandler;
import org.finesys.common.log.trace.proxy.impl.AroundLogProxyChainImpl;
import org.springframework.context.annotation.Configuration;

@Aspect
@Configuration
@RequiredArgsConstructor

/**
 * logMaker切面
 * */
public class LogHelperAspect {

    private final AroundLogHandler aroundLogHandler;

    /**
     * 切点
     */
    @Pointcut("@annotation(org.finesys.common.log.annotation.LogMarker)")
    public void pointcut() {

    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        return aroundLogHandler.around(new AroundLogProxyChainImpl(proceedingJoinPoint));
    }
}
